package com.example.j2025_11_6.Test1;

import com.example.j2025_11_6.Student;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@Controller
public class demo {
    @RequestMapping("/r14")
    public String r14(){
        return "/index.html";
    }
    @ResponseBody
    @RequestMapping("/r15")
    public String r15(){
        return "/index.html";
    }
    @ResponseBody
    @RequestMapping(value = "/r16",produces = "text/plain")
    public String r16(){
        return "<h1>index</h1>";
    }
    @ResponseBody
    @RequestMapping(value = "/r17")
    public Student r17(HttpServletResponse response){
        response.setStatus(404);
        Student student = new Student("zhangsan",18,1);
        return student;
    }
    @ResponseBody
    @RequestMapping("/r18")
    public String r18(HttpServletResponse response){
        response.setStatus(404);
        return "状态设置成功";
    }
    @ResponseBody
    @RequestMapping("/r20")
    public String r20(HttpServletResponse response){
        response.setHeader("myHeader","myHeader");
        return "设置成功";
    }

}
